<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@include file="/html/init.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1 style="color: red;">Danh Sach cac khach san chat luong 1 sao</h1>

<%

	 String url = PortalUtil.getCurrentURL(request);
PortletSession s = renderRequest.getPortletSession(true);
	String localIdString = (String)s.getAttribute("localId", PortletSession.APPLICATION_SCOPE);
		List<Hotel> hotels = null;
		
		
	if(localIdString != null)
	{
		hotels = HotelLocalServiceUtil.getByLocalId(Long.parseLong(localIdString));
	}
	else 
	{
		hotels = HotelLocalServiceUtil.getByQuality(2);
	}
	
	if(hotels.isEmpty() || hotels == null)
	{
		%>
		<h1>Khong co khach san nao duoc tim thay</h1>
		<%
	}
	else
	{
		
		%>
		
		
		<table >
				<%
					int i = 0; 
					int size = hotels.size();
					while(i<(size/4))
					{
						%>
							<tr>
							<%
							for(int j = 0 ; j<4; j++ )
							{
								%>
									<td>
										<table>
										<tr>
										<td>
									 <a href="<%=url+"?hotelId="+hotels.get(i+j).getHotelId()%>"><%=hotels.get(i+j).getHotelName() %></a> 
											
										</td>
										</tr>
										
										<tr>
										
										<td><a href="<%=url+"?hotelId="+hotels.get(i+j).getHotelId()%>"><img src="<%=hotels.get(i+j).getImage()%>"/></a>
											</td>
										</tr>
										</table>
									</td>
								<%
							}
							
							%>
							</tr>
						<%
						i+=4;
					}
					if((size%4)>0)
					{
						%>
						<tr>
						<%
							for(int j = 0 ; j<size%4; j++)
							{
								%>
								<td>
								<table>
										<tr>
										<td>
									 <a href="<%=url+"?hotelId="+hotels.get(i+j).getHotelId()%>"><%=hotels.get(i+j).getHotelName() %></a> 
											
										</td>
										</tr>
										
										<tr>
										
										<td><a href="<%=url+"?hotelId="+hotels.get(i+j).getHotelId()%>"><img src="<%=hotels.get(i+j).getImage()%>"/></a>
											</td>
										</tr>
										</table>
								</td>
								<% 
							}
						%>
						</tr>
						<%
					}
				%>
			</table>
		
		<%
		
		
	}
	
%>

</body>
</html>